package self;

 
public class TestSpeaker {
	
	//定义广播
	private  Speaker   broadcast; 
	
	//定义听众
	//男听众
	private  ManListener   manListener;
	//女听众
	private  LadyListener  ladyListener;
	 
	//构造函数，注册广播和听众
	public TestSpeaker()
	{
	     
	     this.manListener  = new ManListener();
	     this.ladyListener = new LadyListener();
	     
	     this.broadcast = new Speaker();
	     this.broadcast.addLister(manListener);
	     this.broadcast.addLister(ladyListener);
	     
	      
	}
	
	public static void main(String[] args)
	{
		System.out.println("============Case #1: notice All:============================");
		TestSpeaker  testSpeaker = new TestSpeaker();
		testSpeaker.broadcast.setContent("Man need lady");
		testSpeaker.broadcast.notice();
		System.out.println("============Case #2: notice one special listener:============================");
		
		testSpeaker.broadcast.setContent("Man Love lady");
		testSpeaker.broadcast.notice(testSpeaker.ladyListener);
	}

}

/**
 *   原则上要求业务模块进行：松散耦合
 * 
 **/
